
package cn.cloud.all.security.oauth2.config.annotation;

import cn.cloud.all.security.oauth2.provider.ClientDetailsService;

import javax.sql.DataSource;

public class ClientDetailsServiceConfigurer extends SecurityConfigurerAdapter<ClientDetailsService, ClientDetailsServiceBuilder<?>> {

    public ClientDetailsServiceConfigurer(ClientDetailsServiceBuilder<?> builder) {
        setBuilder(builder);
    }

    public void withClientDetails(ClientDetailsService clientDetailsService) throws Exception {
        setBuilder(getBuilder().clients(clientDetailsService));
        this.and();
    }

    public InMemoryClientDetailsServiceBuilder inMemory() throws Exception {
        InMemoryClientDetailsServiceBuilder next = getBuilder().inMemory();
        setBuilder(next);
        return next;
    }

    public JdbcClientDetailsServiceBuilder jdbc(DataSource dataSource) throws Exception {
        JdbcClientDetailsServiceBuilder next = getBuilder().jdbc().dataSource(dataSource);
        setBuilder(next);
        return next;
    }

    @Override
    public void init(ClientDetailsServiceBuilder<?> builder) throws Exception {
    }

    @Override
    public void configure(ClientDetailsServiceBuilder<?> builder) throws Exception {
    }
}
